// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const data = event.data
  return await cloud.openapi.subscribeMessage.send({
    "touser": wxContext.OPENID, // 发给自己直接从 getWXContext 获取
    "templateId": data.templateId,
    "page": data.path,
    "lang": 'zh_CN',
    "data": {
      "thing2": {
        "value": data.title
      },
      "phrase8": {
        "value": '报名成功'
      },
      "thing19": {
        "value": '详细点击查看=>'
      }
    },
    "miniprogramState": 'developer'
  })
}